package com.yufubao.api.controller.applet.discounts;

import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.result.PageUtils;
import com.yufubao.framework.result.ResponseResult;
import com.yufubao.model.pojo.applet.discounts.SkuLadderEntity;
import com.yufubao.service.service.applet.discounts.SkuLadderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;





/**
 * 商品阶梯价格
 *
 * @author zhangzhan
 * @email 52194440@qq.com
 * @date 2024-08-29 16:54:10
 */
@Api("商品阶梯价格/打折价格")
@RestController
@RequestMapping("/applet/skuladder")
public class SkuLadderController {
    @Autowired
    private SkuLadderService skuLadderService;

    /**
     * 列表
     */
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ApiOperation(value = "列表")
    @SystemLog(info = "商品阶梯价格列表")
    public ResponseResult list(@RequestBody Map<String, Object> params){
        PageUtils page = skuLadderService.queryPage(params);

        return ResponseResult.okResultPage("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping(value = "/info/{id}",method = RequestMethod.GET)
    @ApiOperation(value = "信息")
    @SystemLog(info = "商品阶梯价格信息")
    public ResponseResult info(@PathVariable("id") Long id){
		SkuLadderEntity skuLadder = skuLadderService.getById(id);

        return ResponseResult.okResultPage("SkuLadder",skuLadder);
    }

    /**
     * 保存
     */
    @RequestMapping(value = "/save",method = RequestMethod.POST)
    @ApiOperation(value = "保存")
    @SystemLog(info = "商品阶梯价格保存")
    public ResponseResult save(@RequestBody SkuLadderEntity skuLadder){
		skuLadderService.save(skuLadder);

        return ResponseResult.ok();
    }

    /**
     * 修改
     */
    @RequestMapping(value = "/update",method = RequestMethod.PUT)
    @ApiOperation(value = "修改")
    @SystemLog(info = "商品阶梯价格修改")
    public ResponseResult update(@RequestBody SkuLadderEntity skuLadder){
		skuLadderService.updateById(skuLadder);

        return ResponseResult.ok();
    }

    /**
     * 删除
     */
    @RequestMapping(value = "/delete",method = RequestMethod.DELETE)
    @ApiOperation(value = "删除")
    @SystemLog(info = "商品阶梯价格删除")
    public ResponseResult delete(@RequestBody Long[] ids){
		skuLadderService.removeByIds(Arrays.asList(ids));

        return ResponseResult.ok();
    }

}
